home *** CD-ROM | disk | FTP | other *** search
- /*
- This simple extension of the java.awt.Frame class
- contains all the elements necessary to act as the
- main window of an application.
- */
-
- import java.awt.*;
-
- public class Frame1 extends Frame
- {
- public Frame1()
- {
- // This code is automatically generated by Visual Cafe when you add
- // components to the visual environment. It instantiates and initializes
- // the components. To modify the code, only use code syntax that matches
- // what Visual Cafe can generate, or Visual Cafe may be unable to back
- // parse your Java file into its visual environment.
-
- //{{INIT_CONTROLS
- setLayout(null);
- setSize(405,305);
- setVisible(false);
- openFileDialog1.setMode(FileDialog.LOAD);
- openFileDialog1.setTitle("Open");
- //$$ openFileDialog1.move(24,312);
- setTitle("AWT Application");
- //}}
-
- //{{INIT_MENUS
- menu1.setLabel("File");
- menu1.add(newMenuItem);
- newMenuItem.setEnabled(false);
- newMenuItem.setLabel("New");
- newMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_N,false));
- menu1.add(openMenuItem);
- openMenuItem.setLabel("Open...");
- openMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_O,false));
- menu1.add(saveMenuItem);
- saveMenuItem.setEnabled(false);
- saveMenuItem.setLabel("Save");
- saveMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_S,false));
- menu1.add(saveAsMenuItem);
- saveAsMenuItem.setEnabled(false);
- saveAsMenuItem.setLabel("Save As...");
- menu1.add(separatorMenuItem);
- menu1.add(exitMenuItem);
- exitMenuItem.setLabel("Exit");
- mainMenuBar.add(menu1);
- menu2.setLabel("Edit");
- menu2.add(cutMenuItem);
- cutMenuItem.setEnabled(false);
- cutMenuItem.setLabel("Cut");
- cutMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_X,false));
- menu2.add(copyMenuItem);
- copyMenuItem.setEnabled(false);
- copyMenuItem.setLabel("Copy");
- copyMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_C,false));
- menu2.add(pasteMenuItem);
- pasteMenuItem.setEnabled(false);
- pasteMenuItem.setLabel("Paste");
- pasteMenuItem.setShortcut(new MenuShortcut(java.awt.event.KeyEvent.VK_V,false));
- mainMenuBar.add(menu2);
- menu3.setLabel("Help");
- menu3.add(aboutMenuItem);
- aboutMenuItem.setLabel("About...");
- mainMenuBar.add(menu3);
- //$$ mainMenuBar.move(0,312);
- setMenuBar(mainMenuBar);
- //}}
-
- //{{REGISTER_LISTENERS
- SymWindow aSymWindow = new SymWindow();
- this.addWindowListener(aSymWindow);
- SymAction lSymAction = new SymAction();
- openMenuItem.addActionListener(lSymAction);
- exitMenuItem.addActionListener(lSymAction);
- aboutMenuItem.addActionListener(lSymAction);
- //}}
- }
-
- public Frame1(String title)
- {
- this();
- setTitle(title);
- }
-
- /**
- * Shows or hides the component depending on the boolean flag b.
- * @param b if true, show the component; otherwise, hide the component.
- * @see java.awt.Component#isVisible
- */
- public void setVisible(boolean b)
- {
- if(b)
- {
- setLocation(50, 50);
- }
- super.setVisible(b);
- }
-
- static public void main(String args[])
- {
- try
- {
- //Create a new instance of our application's frame, and make it visible.
- (new Frame1()).setVisible(true);
- }
- catch (Throwable t)
- {
- System.err.println(t);
- t.printStackTrace();
- //Ensure the application exits with an error condition.
- System.exit(1);
- }
- }
-
- public void addNotify()
- {
- // Record the size of the window prior to calling parents addNotify.
- Dimension d = getSize();
-
- super.addNotify();
-
- if (fComponentsAdjusted)
- return;
-
- // Adjust components according to the insets
- setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
- Component components[] = getComponents();
- for (int i = 0; i < components.length; i++)
- {
- Point p = components[i].getLocation();
- p.translate(getInsets().left, getInsets().top);
- components[i].setLocation(p);
- }
- fComponentsAdjusted = true;
- }
-
- // Used for addNotify check.
- boolean fComponentsAdjusted = false;
-
- //{{DECLARE_CONTROLS
- java.awt.FileDialog openFileDialog1 = new java.awt.FileDialog(this);
- //}}
-
- //{{DECLARE_MENUS
- java.awt.MenuBar mainMenuBar = new java.awt.MenuBar();
- java.awt.Menu menu1 = new java.awt.Menu();
- java.awt.MenuItem newMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem openMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem saveMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem saveAsMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem separatorMenuItem = new java.awt.MenuItem("-");
- java.awt.MenuItem exitMenuItem = new java.awt.MenuItem();
- java.awt.Menu menu2 = new java.awt.Menu();
- java.awt.MenuItem cutMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem copyMenuItem = new java.awt.MenuItem();
- java.awt.MenuItem pasteMenuItem = new java.awt.MenuItem();
- java.awt.Menu menu3 = new java.awt.Menu();
- java.awt.MenuItem aboutMenuItem = new java.awt.MenuItem();
- //}}
-
- class SymWindow extends java.awt.event.WindowAdapter
- {
- public void windowClosing(java.awt.event.WindowEvent event)
- {
- Object object = event.getSource();
- if (object == Frame1.this)
- Frame1_WindowClosing(event);
- }
- }
-
- void Frame1_WindowClosing(java.awt.event.WindowEvent event)
- {
- // to do: code goes here.
-
- Frame1_WindowClosing_Interaction1(event);
- }
-
-
- void Frame1_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
- {
- try {
- // QuitDialog Create and show as modal
- (new QuitDialog(this, true)).setVisible(true);
- } catch (Exception e) {
- }
- }
-
-
- class SymAction implements java.awt.event.ActionListener
- {
- public void actionPerformed(java.awt.event.ActionEvent event)
- {
- Object object = event.getSource();
- if (object == openMenuItem)
- openMenuItem_ActionPerformed(event);
- else if (object == aboutMenuItem)
- aboutMenuItem_ActionPerformed(event);
- else if (object == exitMenuItem)
- exitMenuItem_ActionPerformed(event);
- }
- }
-
- void openMenuItem_ActionPerformed(java.awt.event.ActionEvent event)
- {
- // to do: code goes here.
-
- openMenuItem_ActionPerformed_Interaction1(event);
- }
-
-
- void openMenuItem_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
- {
- try {
- // OpenFileDialog Create and show as modal
- int defMode = openFileDialog1.getMode();
- String defTitle = openFileDialog1.getTitle();
- String defDirectory = openFileDialog1.getDirectory();
- String defFile = openFileDialog1.getFile();
-
- openFileDialog1 = new java.awt.FileDialog(this, defTitle, defMode);
- openFileDialog1.setDirectory(defDirectory);
- openFileDialog1.setFile(defFile);
- openFileDialog1.setVisible(true);
- } catch (Exception e) {
- }
- }
-
-
- void aboutMenuItem_ActionPerformed(java.awt.event.ActionEvent event)
- {
- // to do: code goes here.
-
- aboutMenuItem_ActionPerformed_Interaction1(event);
- }
-
-
- void aboutMenuItem_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
- {
- try {
- // AboutDialog Create and show as modal
- (new AboutDialog(this, true)).setVisible(true);
- } catch (Exception e) {
- }
- }
-
-
- void exitMenuItem_ActionPerformed(java.awt.event.ActionEvent event)
- {
- // to do: code goes here.
-
- exitMenuItem_ActionPerformed_Interaction1(event);
- }
-
-
- void exitMenuItem_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
- {
- try {
- // QuitDialog Create and show as modal
- (new QuitDialog(this, true)).setVisible(true);
- } catch (Exception e) {
- }
- }
-
- }
-
-